﻿@using Microsoft.Web.Helpers
@model RegisterViewModel

@{
	ViewBag.Title = @Html.GetGlobalResource("PagesTitles", "Register");
    Layout = "~/Views/Shared/_AccountLayout.cshtml";
}

<script type="text/javascript">
    $(document).ready(function () {
        $("#regForm").validate({
            rules: {
                Login: { required: true},
                Email: { required: true },
                Password: { required: true },
                ConfirmPassword: { required: true },
                IsAgree: { required: true }
            },
            messages: {
                Login: { required: "@Html.GetGlobalResource("Common", "FileldRequired")" },
                Email: { required: "@Html.GetGlobalResource("Common", "FileldRequired")" },
                Password: { required: "@Html.GetGlobalResource("Common", "FileldRequired")" },
                ConfirmPassword: { required: "@Html.GetGlobalResource("Common", "FileldRequired")" },
                IsAgree: { required: "@Html.GetGlobalResource("Common", "FileldRequired")" },             
            }

		});
	});

</script>

<h2>@Html.GetGlobalResource("PagesTitles", "Register")</h2>

@if (Model.IsRegistered) {
	<br />
	<label>@Html.GetLocalResource("UserRegistered")</label><br/><br/>
	<input type="button" value="OK" onclick="@string.Format("window.location.href='{0}';", Url.Action("Index", "Home"))"/>
}
else {
	@Html.ValidationSummary()
	using (Html.BeginForm("Register", "Account", FormMethod.Post, new {id = "regForm"})) {
		<label>@Html.GetLocalResource("Login")</label>
		<br/>
		@Html.TextBoxFor(x => x.Login)<br/>
		<div id="loginInvalid" style="color: red; display: none;">@Html.GetLocalResource("LoginExists")</div>
		<div id="loginValid" style="color: green; display: none;">@Html.GetLocalResource("LoginValid")</div>
		<br/>

		<label>@Html.GetLocalResource("Email")</label>
		<br/>
		@Html.TextBoxFor(x => x.Email)<br/>
		<div id="emailInvalid" style="color: red; display: none;">@Html.GetLocalResource("EmailExists")</div>
		<div id="emailValid" style="color: green; display: none;">@Html.GetLocalResource("EmailValid")</div>
		<br/>

		<label>@Html.GetLocalResource("Password")</label>
		<br/>
		@Html.PasswordFor(x => x.Password)<br/>
		<br/>

		<label>@Html.GetLocalResource("ConfirmPassword")</label>
		<br/>
		@Html.PasswordFor(x => x.ConfirmPassword)<br/>
		<br/>

		@Html.CheckBoxFor(x => x.IsAgree)
		<label>@Html.GetLocalResource("Agree")&nbsp;&nbsp;<a href="http://visell.tv/content/20">* @Html.GetLocalResource("OfferLink")</a></label>
		<br/>@*
		<br/>
        <div class="validation"></div>
        
		if (ReCaptcha.PrivateKey != "") {
			<p>@ReCaptcha.GetHtml()</p>
		}
		*@<br/>
    
		<br/>
		@Html.HiddenFor(x => x.FromUserGuid);
		<input type="submit" value="@Html.GetLocalResource("Create")"/>
	}
}